package com.qding.park.manager.service.statis.biz;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.qding.park.manager.adapter.factory.AdapterParkProxyFactory;
import com.qding.park.manager.service.statis.dao.MongodbDao;
import com.qding.park.manager.service.statis.mapper.TbParkspaceStatisMapper;
import com.qding.park.manager.service.statis.mapper.TbReserveStatisMapper;
import com.qding.park.manager.service.statis.mapper.TbUserInfoStatisMapper;

/**
 * @ClassName PayFeeBiz
 * @Description TODO(这里用一句话描述这个类的作用)
 * @author Administrator
 * @Date 2016年8月25日 下午6:45:12
 * @version 1.0.0
 */
@Component("payFeeStatisBiz_statis")
public class PayFeeStatisBiz {

	private static final Log _log = LogFactory.getLog(PayFeeStatisBiz.class);
	/**
	 * @Field @tbReserveMapper : TODO(预定，临停缴费单)
	 */
	@Autowired
	private TbReserveStatisMapper tbReserveMapper;

	/**
	 * @Field @tbUserInfoMapper : TODO(用户)
	 */
	@Autowired
	private TbUserInfoStatisMapper tbUserInfoMapper;

	// /**
	// * @Field @tbFeetradeMapper : TODO(资金流水)
	// */
	// @Autowired
	// private TbFeetradeMapper tbFeetradeMapper;

	/**
	 * @Field @TbParkspaceMapper : TODO(车场)
	 */
	@Autowired
	private TbParkspaceStatisMapper tbParkspaceMapper;

	@Autowired
	private MongodbDao mongodbDao;

	// /**
	// * @Field @TbMonthRentMapper : TODO(月租单)
	// */
	// @Autowired
	// private TbMonthRentMapper tbMonthRentMapper;
	//
	// /**
	// * @Field @tbCarMapper : TODO(这里用一句话描述这个类的作用)
	// */
	// @Autowired
	// private TbCarMapper tbCarMapper;

	@Autowired
	private AdapterParkProxyFactory adapterParkProxyFactory;

	// @Autowired
	// private TbInoutRecordMapper tbInoutRecordMapper;

	/**
	 * createTeneratPayment(代缴费单) TODO(这里描述这个方法适用条件 – 可选) TODO(这里描述这个方法的执行流程 –
	 * 可选) TODO(这里描述这个方法的使用方法 – 可选) TODO(这里描述这个方法的注意事项 – 可选)
	 *
	 * @Title: createTeneratPayment @Description: TODO @param @param
	 * reserver @param @return @param @throws
	 * ServiceCoreException @param @throws AdapterProxyCreateFail @param @throws
	 * NetWorkException @param @throws AdapterException 设定文件 @return String
	 * 返回类型 @throws
	 */
//	@Transactional(rollbackFor = Exception.class)
//	public void createTeneratPayment(TbReserve reserver)
//			throws ServiceCoreException, AdapterProxyCreateFail, NetWorkException, AdapterException {
//		// 查询用户信息
//		String bjuserid = reserver.getBjuserId();
////		TbUserInfo tbUserInfo = tbUserInfoMapper.queryUserByBjUserId(bjuserid);
//		TbUserInfo tbUserInfo = tbUserInfoMapper.queryUseByBjuseridType(bjuserid, UserTypeEnum.REGISTER_USER.getType());
//		String carNumStrs = tbUserInfo.getCarNum();
//		String carNum = reserver.getCarNum();// 车牌
//		// int parkId=reserver.getParkID();//车场
//
//		// 查询车牌进场记录
//		NcParkInoutInfo ncParkInoutInfo = mongodbDao.queryIncheckByCarnum(carNum);
//
//		if (ncParkInoutInfo == null || ncParkInoutInfo.getOutTime() != null) {
//			// 车辆没有停在此车场
//			throw new ServiceCoreException(ServiceCoreException.TypeEnum.EXCEPTION_CAR_NOTIN_PARK.getId(), null,
//					ExceptionMessage.createExceptionMessage(
//							ServiceCoreException.TypeEnum.EXCEPTION_CAR_NOTIN_PARK.getDesc(), "车辆未进场，无法缴费",
//							" 车牌=" + carNum));
//		}
//
//		int parkId = ncParkInoutInfo.getParkId();
//
//		// 查询车场信息
//		TbParkspace tbParkspace = tbParkspaceMapper.queryParkInfoByParkId(parkId);
//
//		reserver.setUserID(tbUserInfo.getId());
//		reserver.setParkName(tbParkspace.getName());
//		int userId = tbUserInfo.getId();
//		reserver.setId(OrderNumUtil.getOrderNum(userId,OrderServiceType.TEMP_PAY.getTag()));
//		/******* 这里要到线下查询临停缴费单详情 ************/
//		int supplierId = tbParkspace.getSupplierId();
//		String parkCode = tbParkspace.getParkCode();
//		AdapterProxy adapterProxy = adapterParkProxyFactory.createAdapterParkProxyBySupplierId(supplierId);
//		AdTempPayOrder apTempPayOrder = adapterProxy.getPayFeeAdapter().createTempPayment(parkCode, carNum);
//
//		reserver.setDeposit(apTempPayOrder.getPayValue());
//		reserver.setParkID(parkId);
//		// reserver.setReserverType(ReserverTypeEnum.GENERATION.getType());
//		reserver.setStatus(ReserverStatusEnum.TEMP_PAY_UNPAYED.getStatus());
//		reserver.setCheckInTime(apTempPayOrder.getEnterTime());
//		reserver.setCheckOutTime(DateUtils.addSecond(reserver.getCheckInTime(), apTempPayOrder.getParkingTime()));
//		reserver.setParkOrderId(apTempPayOrder.getOrderId());
//		reserver.setParkSerial(apTempPayOrder.getParkingSerial());
//		/******************/
//		
////		int num = tbReserveMapper.save(reserver);
//		
////		return reserver.getId();
//	}
	//

//	public TbReserve calTempParkingMoney(int supplyID, String parkCode, int userId, String carNum)
//			throws BaseException {
//		
//		// 查询车场信息
//		TbParkspace tbParkspace = tbParkspaceMapper.queryParkInfoByCodeSupplier(parkCode, supplyID);
//
//		/******* 这里要到线下查询临停缴费单详情 ************/
//		int supplierId = tbParkspace.getSupplierId();
//		AdapterProxy adapterProxy = adapterParkProxyFactory.createAdapterParkProxyBySupplierId(supplierId);
//		AdTempPayOrder apTempPayOrder = adapterProxy.getPayFeeAdapter().createTempPayment(parkCode, carNum);
//		TbReserve reserver = new TbReserve();
//		reserver.setCarNum(carNum);
//		reserver.setId(OrderNumUtil.getOrderNum(userId,OrderServiceType.TEMP_PAY.getTag()));
//		reserver.setUserID(userId);
//		reserver.setParkName(tbParkspace.getName());
//		reserver.setDeposit(apTempPayOrder.getPayValue());
//		reserver.setParkID(tbParkspace.getId());
//		// reserver.setReserverType(ReserverTypeEnum.GENERATION.getType());
//		reserver.setStatus(ReserverStatusEnum.TEMP_PAY_UNPAYED.getStatus());
//		reserver.setCheckInTime(apTempPayOrder.getEnterTime());
//		reserver.setCheckOutTime(DateUtils.addSecond(reserver.getCheckInTime(), apTempPayOrder.getParkingTime()));
//		reserver.setParkOrderId(apTempPayOrder.getOrderId());
//		reserver.setParkSerial(apTempPayOrder.getParkingSerial());
//		reserver.setReserverType(ReserverTypeEnum.GENERATION.getType());
//		/******************/
//		return reserver;
//	}
	

}
